from django.db import models


# Create your models here.

class Users(models.Model):
    # 用户名
    name = models.CharField(max_length=100)
    # 手机号
    phone = models.CharField(max_length=11)
    # 密码
    password = models.CharField(max_length=100)
    # 头像
    img = models.ImageField(upload_to='img', null=True, blank=True)
    # 积分
    score = models.IntegerField(default=0)

    # 是否会员
    # isvip = models.BooleanField(default=False,verbose_name='是否会员')
    # 是否实名
    # issm = models.BooleanField(default=False,verbose_name='是否实名')

    def __str__(self):
        # 返回用户名
        return self.name
        # 返回手机号
        # return self.phone

    class Meta:
        # 数据库表名
        db_table = 'users'


class LoginType(models.Model):
    name = models.CharField(max_length=100)

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'login_type'


class UserLogin(models.Model):
    # 用户外键，关联Users表
    user = models.ForeignKey(Users, on_delete=models.CASCADE)
    # 登录类型外键，关联LoginType表
    login_type = models.ForeignKey(LoginType, on_delete=models.CASCADE)
    # token字段，最大长度为1000
    token = models.CharField(max_length=1000)
    # retoken字段，最大长度为1000
    retoken = models.CharField(max_length=1000)
    # uid字段，最大长度为1000
    uid = models.CharField(max_length=1000)

    class Meta:
        # 数据库表名为user_login
        db_table = 'user_login'



